<?php

namespace app\backend\model;

use think\Model;

class Role extends Model
{
    protected $table = 'blog_role';

    public function setNodeAttr($value)
    {
        if (!empty($value)){
            $str = "";

            foreach ($value as $item)
            {
                $str .= $item.",";
            }
            $value = rtrim($str, ',');
        }

        return $value;

    }

    //同一个用户组有多个不同的用户
    public function user()
    {
        return $this->hasMany('User', 'role_id', 'id');
    }
}
